// Evol scripts.
// Authors:
//    Hal9000
//    Qwerty Dragon
//    Reid
// Description:
//    Elmo's twin
//    Charged of an important quest from Nard, he asks you to help other sailors to keep their box to the ship.
// Variable:
//    0   ShipQuests_Couwan
//    1   ShipQuests_Nard
//    2   ShipQuests_Gugli
// Values:
//    00   Never talked with Couwan.
//    01   Spoke, and received the quest scam.
//    02   Done quest scam.
//    10   Introduction of the box and Nard. This is displayed when the player never spoke to Nard or his box.
//    11   Nard spoke and gave access to the outdoor of the ship.
//    12   Completed the quest.
//    13   Opened the chest and finished the introduction.
//    20   Never talked with Gugli.
//    21   Gugli gives you the task.
//    22   Gave all of the box to Gugli.

000-1,85,108,0	script	Gugli	NPC_GUGLI,{

OnTalk:
    mesn;
    .@nard = getq(ShipQuests_Nard);
    .@gugli = getq(ShipQuests_Gugli);
    .@gado = getq(ShipQuests_ChefGado);

    if (.@nard > 3) goto L_AllComplete;
    if (.@nard > 1 || .@gugli == 2) goto L_TaskCompleted;
    if (.@gugli == 1) goto L_TaskGiven;

    mesq lg("Hi @@, I heard the captain sent you down here, uh?", "Hi @@, I heard the captain sent you down here, uh?", strcharinfo(0));
    next;
    mesq l("What an unexpected pleasure, your help is always welcome!");
    next;
    mesq l("As you may know, we are explorers on a long distance voyage, and our swashbuckling mariners need to store enough food to survive. You don't know how dangerous the sea life can be.");
    next;

    select
        l("Actually, I have an in-depth knowledge of this type of life.");

    mes "";
    mesn;
    mesq lg("Well, even though you have been rescued by us, it doesn't make you an expert sailor, am I right?");
    next;
    mesq l("But let's talk about this island. We're docking here to find some fine quality goods.");
    next;
    mesq l("We usually dock around these small isles because they provide us some of the best food of all the archipelago.");
    next;
    mesq l("At the moment, our crew is busy collecting @@s, @@s and @@s.", getitemlink(513), getitemlink(515), getitemlink(509));
    next;

    select
        l("So, what can I do for you?");

    mes "";
    mesn;
    mesq l("Right! Ours is an earthsea realm. You see, sailors are swift at their tasks when out of sight of land, but docked by this verdant jewel, they have it so good, they are just taking too much time bringing all the food back to the ship. Maybe you can help them.");
    next;
    mesq l("The captain wants:");
    mesq l("- 2 @@", getitemlink(714));
    mesq l("- 2 @@", getitemlink(715));
    mesq l("- 2 @@", getitemlink(716));
    next;
    mesq l("Ask sailors around here they shouldn't be so far away.");
    next;

    setq ShipQuests_Gugli, 1;
    close;

L_TaskGiven:
    mesq l("Great to see you! What can I do for you today?");
    next;

    if (getq(ShipQuests_Ale) == 1 && getq(ShipQuests_Astapolos) == 1 && getq(ShipQuests_Gulukan) == 1 && getq(ShipQuests_Jalad) == 1 && getq(ShipQuests_QMuller) == 1 && getq(ShipQuests_Tibbo) == 1) goto L_MenuDone;

L_Menu:
    menu
        rif(getq(ShipQuests_Couwan) == 1, l("Couwan gave me this box, it is for you.")), L_Couwan,
        rif(countitemcolor(714) > 0 || countitemcolor(715) > 0 || countitemcolor(716) > 0, l("I have some food for you.")), L_CollectSmthing,
        rif(getq(ShipQuests_Gugli) < 2, l("Who should I search for?")), L_SailorNames,
        rif(getq(ShipQuests_Gugli) < 2, l("Where can I find your crew?")), L_Location,
        l("Bye!"), L_Quit;

L_MenuDone:
    menu
        rif(getq(ShipQuests_Couwan) == 1, l("Couwan gave me this box, it is for you.")), L_Couwan,
        l("I have collected all the boxes you needed."), L_TaskDone,
        l("See you!"), L_Quit;

L_SailorNames:
    mes "";
    mesn;
    mesq l("Ale and Tibbo should bring 2 boxes of @@s, Astapolos and Gulukan 2 of @@s and Jalad and Q'Muller were charged of the boxes of @@s.", getitemlink(509), getitemlink(513), getitemlink(515));
    next;
    mesq l("Do you need any other information?");
    next;

    goto L_Menu;

L_CollectSmthing:
    mes "";
    mesn;
    mesq l("Good job!");
    next;

    delitem 714, countitem(714);
    delitem 715, countitem(715);
    delitem 716, countitem(716);

    mesq l("You still need to give me boxes from: ");
    if (getq(ShipQuests_Astapolos) == 0) mesq l("- Astapolos");
    if (getq(ShipQuests_Ale) == 0) mesq l("- Ale");
    if (getq(ShipQuests_Gulukan) == 0) mesq l("- Gulukan");
    if (getq(ShipQuests_Jalad) == 0) mesq l("- Jalad");
    if (getq(ShipQuests_QMuller) == 0) mesq l("- Q'Muller");
    if (getq(ShipQuests_Tibbo) == 0) mesq l("- Tibbo");

    close;

L_Couwan:
    mes "";
    mesn;
    mesq l("What?! This tritan is the worse shirker I ever met!");
    next;
    mesq l("Well, thanks for the box. But... He was supposed to bring it back to me himself. I never asked him to give it to you!");
    next;
    mesq l("Take these coins in exchange and be careful.");
    next;
    mesq l("Not everybody has a kind mind. Scammers can be anywhere, even among us!");
    next;
    mesq l("May this be a lesson for you.");

    if (countitemcolor(713) > 0) delitem 713, 1;
    setq ShipQuests_Couwan, 2;
    Zeny = Zeny + 10;
    getexp 40, 0;
    message strcharinfo(0), l("You receive @@ E!", 10);

    close;

L_Location:
    mes "";
    mesn;
    mesq l("There are 6 sailors who will need your help. They are all around the island.");
    next;
    mesq l("I can't really help you find them since I've been checking the... Hmm... Landscape, since morning...");
    next;
    mesq l("You can try talking with some other sailors to get some information about that.");
    next;

    .@r = rand(3000)/1000;
    if (.@r == 1) goto L_Silvio;
    if (.@r == 2) goto L_Lean;

    setcamnpc "Sapartan";
    mesq l("Max and Sapartan for example?");
    next;

    restorecam;
    close;

L_Silvio:
    setcamnpc "Silvio";
    mesq l("Silvio for example?");
    next;

    restorecam;
    close;

L_Lean:
    setcamnpc "Lean";
    mesq l("Lean for example?");
    next;

    restorecam;
    close;

L_TaskDone:
    if (countitemcolor(714) == 2) delitem 714, 2;
    if (countitemcolor(715) == 2) delitem 715, 2;
    if (countitemcolor(716) == 2) delitem 716, 2;
    if (countitemcolor(714) == 1) delitem 714, 1;
    if (countitemcolor(715) == 1) delitem 715, 1;
    if (countitemcolor(716) == 1) delitem 716, 1;
    setq ShipQuests_Gugli, 2;

    Zeny = Zeny + 250;
    getexp 50, 0;

    mes "";
    mesn;
    mesq l("Well done! The ship is now ready to sail again!");
    next;
    mesq l("You should inform Nard of the progress made in loading food and supplies on to the boat. He will be pleased to hear that good news!");

    close;

L_TaskCompleted:
    mesq l("You are now part of the crew... At least for us down here!");
    next;
    mesq l("You should inform Nard of the progress made in loading food and supplies on to the boat. He will be pleased to hear that good news!");
    next;
    mesq l("Tell him that everything went fine and that we're almost done with the requisitions.");
    next;

    goto L_Menu;

L_AllComplete:
    mesq l("Elmo told me what Nard said, congrats!");
    next;
    mesq lg("You're one of us now, that's great! I was sure that you were a kind lady when I first saw you!", "You're one of us now, that's great! I was sure that you were a good man when I first saw you!");
    next;

    goto L_Menu;

L_Quit:
    closedialog;
    close;

OnInit:
    .sex = G_MALE;
    .distance = 2;
    end;
}

000-1,83,107,0	script	GugliBarrierCheck	NPC_HIDDEN,2,0,{
    .@gugli = getq(ShipQuests_Gugli);
    if (.@gugli > 0) close;
    doevent "Gugli::OnTalk";
    close;
}
